package com.mini.config;

import com.aliyun.oss.OSSClient;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhangxiaobin
 * @title: AliClient
 * @description: TODO
 * @date 2019/10/1015:02
 */
@Configuration
public class AliClient {

    @Value("${ali.region}")
    String regionId;

    @Value("${ali.accesskey.id}")
    String accessKeyId;

    @Value("${ali.accesskey.secret}")
    String accessKeySecret;

    @Value("${ali.oss.endpoint}")
    String ossEndpoint;

    @Bean
    public IAcsClient client(){
        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
        IAcsClient client = new DefaultAcsClient(profile);
        return client;
    }

    @Bean
    public OSSClient ossClient(){
        OSSClient client = new OSSClient(ossEndpoint,accessKeyId, accessKeySecret);
        return client;
    }

}
